﻿$.extend({
    /*
     *  Apply date picker UI widget
     */
    applyRangeDatePickerWidget: function($startdate, $deadline, defaultStartDate, defaultDeadline) {
        var currentDateFormat = $('#hCurrentDateFormat').val().toLowerCase().replace('yyyy', 'yy'),
            languageCode = $("#hLangCode").val();

        $startdate.data('data-backup', defaultStartDate).datepicker({
            showAnim: 'slideDown',
            dateFormat: currentDateFormat,
            maxDate: defaultDeadline,
            onClose: function(selectedDate) {
                $deadline.datepicker("option", "minDate", selectedDate);
            }
        }).datepicker("option", $.datepicker.regional[languageCode]).val(defaultStartDate);

        $deadline.data('data-backup', defaultDeadline).datepicker({
            showAnim: 'slideDown',
            dateFormat: currentDateFormat,
            minDate: defaultStartDate,
            onClose: function(selectedDate) {
                $startdate.datepicker("option", "maxDate", selectedDate);
            }
        }).datepicker("option", $.datepicker.regional[languageCode]).val(defaultDeadline);
    }
});